home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / DCLAP 6d / dclap6d / DBio / DSeqPrintSubs.h < prev    next >
Text File  |  1996-07-05  |  12KB  |  370 lines

  1. // DSeqPrintSubs.h
  2. // d.g.gilbert 
  3.  
  4. #ifndef _DSEQPRINTSUBS_
  5. #define _DSEQPRINTSUBS_
  6.  
  7. #include <ncbi.h>
  8. #include <DTableView.h>
  9. #include <DWindow.h>
  10. #include <DMethods.h>
  11.  
  12. class DPopupList;
  13.  
  14. enum FonStyles { 
  15.     kPlain = 0, kItalic = 1, kBold = 2, kUnderline = 4 
  16.     };
  17.  
  18. enum {
  19.     kShadeInvert = 1,
  20.     kShadeGray50 = 2,
  21.     kShadeGray25 = 3,
  22.     kShadeGray75 = 4,
  23.     kShadeStipple50    = 5,
  24.     kShadeStipple25    = 6,
  25.     kShadeStipple75    = 7,
  26.     
  27.     mColorButHit = 1001,
  28.     mMonoButHit    = 1002,
  29.  
  30.     kFontDescent = 2,
  31.     kIndexRise = 1,
  32.  
  33.     kOutPICT = 1,
  34.     kOutText = 2,
  35.     
  36.   kNameWidth  = 80,
  37.   kIndexWidth = 40,
  38.   kItemWidth  = 12,
  39.     kNucSpace     = 0, //was 2
  40.     kBasesPerLine = 60, // was 50
  41.   //kSeqWidth = kItemWidth * kBasesPerLine,
  42.     kNucBorder    = 6,
  43.     kSeqLinesPerParag = 5,
  44.     kLinesPerParag= 7, // kSeqLinesPerParag + 2; // 5 seq + top index + top spacer
  45.  
  46.     kMacdrawHeaderSize= 512
  47.     };
  48.  
  49. enum SeqRowType { kSpacer, kTopline, kSeqline };
  50.  
  51.  
  52.  
  53.  
  54.  
  55. class DSeqPrintPrefs : public DWindow {
  56. public:
  57.     enum { 
  58.             kSeqPrintPrefID = 1232,
  59.             kStylePlain,kStyleItalic,kStyleBold,kStyleUnderline,
  60.             cIndexLeft, cIndexRight, cIndexTop, 
  61.             cNameLeft, cNameRight,
  62.             cColored,
  63.             cShowComplement,cThreeLetAA,cOnlyORF,
  64.             cShowAA1,cShowAA2,cShowAA3,
  65.             cShowCompAA1,cShowCompAA2,cShowCompAA3,
  66.             cShowCutpoints,cShowAllZymes,cShowExcludedCutters,cShowNoncutters,
  67.             cOutText, cOutPICT
  68.             };
  69.  
  70.     static char *gNameFontName, *gBaseFontName, *gIndexFontName;
  71.     static Nlm_FonT    gNameFont, gBaseFont, gIndexFont;
  72.     static short gNameFontSize, gBaseFontSize, gIndexFontSize;
  73.     static short gNameStyle, gBaseStyle, gIndexStyle;
  74.     static Boolean gNameLeft,gNameRight,gIndexLeft,gIndexRight,gIndexTop, gColored;
  75.     static short gBasesPerLine, gOutFormat;
  76.         // restmap prefs ..
  77.     static Boolean  gShowComplement,gThreeLetAA, gOnlyORF,
  78.                 gShowAA1,gShowAA2,gShowAA3,
  79.                 gShowCompAA1,gShowCompAA2,gShowCompAA3,
  80.                 gShowAllZymes,gShowCutpoints,gShowExcludedCutters,gShowNoncutters;
  81.     static short    gREMinCuts, gREMaxCuts;
  82.     
  83.     static void InitGlobals();
  84.     static void SaveGlobals();
  85.  
  86.     DPopupMenu  * fNameFontMenu, * fBaseFontMenu, *fIndexFontMenu,
  87.                             * fNameStyleMenu, *fBaseStyleMenu, *fIndexStyleMenu;
  88.     DPopupList  * fOutFormPop;
  89.     DSwitchBox    * fNameSizeSw, * fBaseSizeSw, *fIndexSizeSw;
  90.     DEditText        * fREMinCuts, * fREMaxCuts, * fBasePerLine;
  91.     Boolean               fNeedSave;
  92.     
  93.     DSeqPrintPrefs();
  94.     virtual ~DSeqPrintPrefs();
  95.     virtual void Initialize();
  96.     virtual void Open();
  97.     virtual void Close();
  98.     virtual void OkayAction();
  99.     virtual Boolean IsMyAction(DTaskMaster* action); 
  100.     virtual void NewFontCluster(char* title, DView* mainview,
  101.                     DPopupMenu*& mfont, DPopupMenu*& mstyle, DSwitchBox*& swsize,
  102.                     char* fontname, short fontstyle, short fontsize );
  103.                     
  104. };
  105.  
  106.  
  107. class DDrawMapRow : public DObject {
  108. public:
  109.     enum { kNoIndex = -999, kMaxLinebuf= 1024 };
  110.     static char fLinebuf[kMaxLinebuf+1];
  111.     Nlm_FonT    fFont; 
  112.     char    * fName;
  113.     short      fHeight, fRowOffset, fLinecount, fItemrow;
  114.  
  115.     DDrawMapRow() : 
  116.         fFont(NULL), fName(NULL), fHeight(Nlm_stdLineHeight), 
  117.         fRowOffset(-1), fLinecount(0), fItemrow(0) 
  118.         {}
  119.     virtual void Draw( Nlm_RecT& r, short row, short col, long startitem, long stopitem) {}
  120.     virtual const char* Write( short row, short col, long startitem, long stopitem) { return ""; }
  121.     virtual char* GetName(short row) { return fName; }
  122.     virtual short GetIndex(short item) { return item; }
  123.     virtual short GetHeight( Nlm_RecT& r, short row, long startitem, long stopitem) { return fHeight; }
  124.     virtual Boolean DoLeftName() { return false; }
  125.     virtual void  Clip( Nlm_RecT& r, short row, long startitem, long stopitem,
  126.                                          Nlm_RecT& viewr, Nlm_RegioN cliprgn)
  127.     {
  128.         Nlm_ClipRgn( cliprgn);
  129.     }
  130. };
  131.  
  132.  
  133. class DDrawSpacer : public DDrawMapRow {
  134. public:
  135.     char *fTitle;
  136.     DDrawSpacer( char* title= NULL, Nlm_FonT itsFont = NULL) : fTitle(title) { fFont= itsFont; }
  137.     virtual void Draw( Nlm_RecT& r, short row, short col, long startitem, long stopitem);
  138.     virtual const char* Write( short row, short col, long startitem, long stopitem);
  139.     virtual short GetIndex(short item) { return kNoIndex; }
  140. };
  141.  
  142.  
  143. class DDrawIndexRow : public DDrawMapRow {
  144. public:
  145.     Nlm_Boolean fIsUp;
  146.     short    fItemWidth;
  147.     DDrawIndexRow( Nlm_FonT itsFont, short itemWidth, Nlm_Boolean upright= true) : 
  148.         fIsUp(upright),fItemWidth(itemWidth) 
  149.         { 
  150.             fFont= itsFont; 
  151.             if (fFont) Nlm_SelectFont(fFont);
  152.             fHeight= 3 + Nlm_LineHeight();
  153.         }
  154.     virtual void Draw( Nlm_RecT& r, short row, short col, long startitem, long stopitem);
  155.     virtual const char* Write( short row, short col, long startitem, long stopitem);
  156.     virtual short GetIndex(short item) { return kNoIndex; }
  157. };
  158.  
  159.  
  160. class DDrawSeqRow : public DDrawMapRow {
  161. public:
  162.     char        fNameStore[20];
  163.     DSeqPrintView * fView;
  164.     ulong    * fColors;
  165.     DSequence * fSeq, * fTopSeq, * fBotSeq;
  166.     char    * fBases;
  167.     char    * fFirstcommon, * fCommonbase;
  168.     long         fLength;
  169.     short        fItemWidth;
  170.     DList *    fStyles;
  171.     
  172.     DDrawSeqRow(Nlm_FonT itsFont, DSeqPrintView* itsView, DSequence* itsSeq,
  173.                                  DList* itsStyles, char* name, ulong* colors);
  174.     virtual void Draw( Nlm_RecT& r, short row, short col, long startitem, long stopitem);    
  175.     virtual const char* Write( short row, short col, long startitem, long stopitem);
  176.     virtual DSeqStyle* GetStyle(long ibase, short masklevel, DSequence* aSeq);
  177. };
  178.  
  179.  
  180. class DDrawManySeqRow : public DDrawSeqRow {
  181. public:
  182.     DSeqList * fSeqList;
  183.     //short             fLinesPerparag, fTopPerparag;
  184.     
  185.     DDrawManySeqRow(Nlm_FonT itsFont, DSeqPrintView* itsView, 
  186.                                     DSeqList* seqlist, long seqIndex, DList* itsStyles, ulong* colors,
  187.                                     char* commonbases, char* firstcommon);
  188. };
  189.  
  190.  
  191. class DDrawAminoRow : public DDrawMapRow {
  192. public:
  193.     char        fNameStore[20];
  194.     char        * fBases;
  195.     short        fFrame, fItemWidth;
  196.     Boolean fThreeLet, fOnlyORF;
  197.     DSequence * fAAseq;
  198.     long        fLength;
  199.     
  200.     DDrawAminoRow(Nlm_FonT itsFont, DSequence* itsSeq, short frame);
  201.     virtual ~DDrawAminoRow() { if (fAAseq) delete fAAseq; }
  202.     virtual void Draw( Nlm_RecT& r, short row, short col, long startitem, long stopitem);    
  203.     virtual const char* Write( short row, short col, long startitem, long stopitem);
  204.     virtual short GetIndex(short item) { return kNoIndex; }
  205. };
  206.  
  207. class DDrawORFRow : public DDrawSeqRow {
  208. public:
  209.     char        fNameStore[20];
  210.     DSequence * fAAseq;
  211.     short        fFrame;
  212.  
  213.     DDrawORFRow(Nlm_FonT itsFont, DSeqPrintView* itsView, DSequence* itsSeq,
  214.                                  DList* itsStyles, char* name, ulong* colors, short frame);
  215.     virtual ~DDrawORFRow();
  216.     virtual void Draw( Nlm_RecT& r, short row, short col, long startitem, long stopitem);    
  217.     virtual const char* Write( short row, short col, long startitem, long stopitem);
  218.     virtual short GetIndex(short item) { return kNoIndex; }
  219. };
  220.  
  221.  
  222. class DDrawZymeTable : public DDrawMapRow { 
  223. public:
  224.     char** fLinelist;
  225.     char * fTableTitle;
  226.     
  227.     DDrawZymeTable(Nlm_FonT itsFont, DREMap* itsREMap, short rowoffset);
  228.     virtual ~DDrawZymeTable();
  229.     virtual void Draw( Nlm_RecT& r, short row, short col, long startitem, long stopitem);    
  230.     virtual const char* Write( short row, short col, long startitem, long stopitem);
  231.     virtual short GetIndex(short item) { return kNoIndex; }
  232.     virtual char* TableLine(short atline); 
  233.     virtual void  Clip( Nlm_RecT& r, short row, long startitem, long stopitem,
  234.                                              Nlm_RecT& viewr, Nlm_RegioN cliprgn);
  235. };
  236.  
  237. class DDrawAllZymeTable : public DDrawZymeTable { 
  238. public:
  239.     DDrawAllZymeTable(Nlm_FonT itsFont, DREMap* itsREMap, short rowoffset);
  240. };
  241.  
  242. class DDrawNocutZymeTable : public DDrawZymeTable { 
  243. public:
  244.     DDrawNocutZymeTable(Nlm_FonT itsFont, DREMap* itsREMap, short rowoffset, 
  245.                                             short mincuts = 0, short maxcuts = 0);
  246. };
  247.  
  248.  
  249. class DDrawZymeCutTable : public DDrawZymeTable { 
  250. public:
  251.     DRECutsItem * fCutList;               
  252.     long    fCutcount;
  253.     short    fCuttersCount;             //# zymes that cut
  254.     
  255.     DDrawZymeCutTable(Nlm_FonT itsFont, DREMap* itsREMap, short rowoffset);
  256.     virtual ~DDrawZymeCutTable();
  257.     virtual char* TableLine(short atline); 
  258.     virtual char* GetName(short row); 
  259.     virtual Boolean DoLeftName() { return true; }
  260. };
  261.  
  262. class DDrawZymeRow : public DDrawMapRow { 
  263. public:
  264.   DSequence * fSeq, * fCoSeq;
  265.     DREMap * fREMap;
  266.     short        fMinCuts, fMaxCuts;
  267.     DRECutsItem * fCutList;
  268.     Boolean     fGoodMap;
  269.     
  270.     DDrawZymeRow( Nlm_FonT itsFont, DSequence* itsSeq);
  271.     virtual ~DDrawZymeRow() { delete fREMap; }
  272.     virtual short DrawOrMeasure( Nlm_Boolean doDraw, Nlm_RecT& r, short row, long startitem, long stopitem);    
  273.     virtual void  Draw( Nlm_RecT& r, short row, short col, long startitem, long stopitem);    
  274.     virtual const char* Write( short row, short col, long startitem, long stopitem);
  275.     virtual short GetIndex(short item) { return kNoIndex; }
  276.     virtual short GetHeight( Nlm_RecT& r, short row, long startitem, long stopitem); 
  277.     virtual void  Clip( Nlm_RecT& r, short row, long startitem, long stopitem,
  278.                                              Nlm_RecT& viewr, Nlm_RegioN cliprgn);
  279. };
  280.  
  281.  
  282. class DSeqPrintView : public DTableView 
  283. {
  284. public:
  285.     Boolean        fOneseq, fDoLeftName, fDoRightName, 
  286.                         fDoTopIndex, fDoLeftIndex, fDoRightIndex; 
  287.     Nlm_FonT    fNameFont, fNumFont, fBaseFont;
  288.     short         fBaseWidth, fIndexWidth, fIndexWidthCnt, fNameWidth, fNameWidthCnt, 
  289.                         fSeqsperparag, fExtrarows, fSeqLinesPerParag, fLinesPerParag, 
  290.                         fTopPerparag, fBasesPerLine, fTenSpacer;
  291.     long             fFirstBase, fNbases, fMaxbases, fSeqWidth;
  292.     DSeqPrintDoc    * fDoc;
  293.     DSeqList    * fSeqList;  
  294.     DSequence * fSeq;
  295.     DList            * fDrawRowList, * fStyles;
  296.     DFile            * fFile;
  297.     char            * fCommonbase, * fFirstcommon;
  298.  
  299.     //DCheckBox*        fLeftName, fRightName, fTopIndex, fLeftIndex, fRightIndex ;
  300.     //DDlogTextView*        fStyleName, fStyleBase, fStyleNums; 
  301.     
  302.     DSeqPrintView( long id, DView* itsSuper, DSeqPrintDoc* itsDocument,
  303.                                  DSeqList* itsSeqList, long firstbase, long nbases,
  304.                                  long pixwidth, long pixheight);
  305.     virtual ~DSeqPrintView();
  306.     virtual void Initialize();
  307.     virtual void FreeLists();
  308.  
  309.     virtual void MakeDrawList();
  310.     virtual void Draw();
  311.     virtual void DrawRow(Nlm_RecT r, long row);
  312.     virtual void IndexFromRow( long row, long& itemrow, long& seqline, long& startitem, long& stopitem);
  313.     virtual void GetReadyToShow();
  314.     virtual void DrawSideIndex( Nlm_RecT& aRect, long atBase, long leftBorder);
  315.     virtual void WriteSideIndex( long atBase, long leftBorder);
  316.     virtual void DrawName( Nlm_RecT& aRect, short rightBorder, char* name);
  317.     virtual void WriteName( short rightBorder, char* name);
  318.     virtual short GetExtraRows() { return fExtrarows; }
  319.  
  320.     virtual void WriteTo(DFile* aFile);
  321.     virtual    void WriteRow(long row);
  322. };
  323.  
  324.  
  325. class DAlnPrintView : public DSeqPrintView {
  326. public:
  327.  
  328.     DAlnPrintView( long id, DView* itsSuper, DSeqPrintDoc* itsDocument,
  329.                                  DSeqList* itsSeqList, long firstbase, long nbases, long pixwidth, long pixheight);
  330. };
  331.  
  332.  
  333.  
  334. class DREMapPrintView : public DSeqPrintView {
  335. public:
  336.     Boolean fDoAAline[6];
  337.     Boolean fDoSeqLine,fDoMidIndex,fDoCoseqLine,fDoZymeLine;
  338.     short        fMaxseqrow;
  339.     
  340.     DREMapPrintView( long id, DView* itsSuper, DSeqPrintDoc* itsDocument,
  341.                     DSeqList* itsSeqList, long firstbase, long nbases, long pixwidth, long pixheight);
  342.     virtual void Initialize();
  343.     virtual void MakeDrawList();
  344.     virtual void SetScrollPage();
  345.     virtual void IndexFromRow( long row, long& itemrow, long& seqline, long& startitem, long& stopitem);
  346. };
  347.  
  348.  
  349.  
  350.  
  351.  
  352. class DAsmPrintView : public DSeqPrintView {
  353. public:
  354.     Boolean fDoAAline[6];
  355.     Boolean fDoSeqLine,fDoMidIndex,fDoCoseqLine,fDoZymeLine;
  356.     short        fMaxseqrow;
  357.     
  358.     DAsmPrintView( long id, DView* itsSuper, DSeqPrintDoc* itsDocument,
  359.                     DSeqList* itsSeqList, long firstbase, long nbases, long pixwidth, long pixheight);
  360.     virtual void Initialize();
  361.     virtual void MakeDrawList();
  362.     virtual void SetScrollPage();
  363.     virtual void IndexFromRow( long row, long& itemrow, long& seqline, long& startitem, long& stopitem);
  364. };
  365.  
  366.  
  367. #endif  
  368.  
  369.  
  370.